
import type { PageParams } from "@/types/common"
import type { Role, RoleData, RoleDetail, RoleParams, RoleUser, RoleUserData } from "@/types/system"
import { request } from "@/utils/reuqest"


export const getRoleListAPI =()=>{
  return request<Role[]>('/park/sys/role')
}

export const getTreeListAPI =()=>{
  return request<RoleData[]>('/park/sys/permision/all/tree')
}

/**
 * 查询当前角色详情 权限和分配人数
 */
export const getRoleDetailAPI  = (roleId:number)=>{
  return request<RoleDetail>(`/park/sys/role/${roleId}`)
}
/**
 * 查询当前角色关联的用户列表
 */
export const getRoleUserAPI = (roleId:number,params?:PageParams)=>{
  return request<RoleUserData>(`/park/sys/roleUser/${roleId}`,'GET',params)
}


/**
 * 角色管理-添加角色
 * @param data 
 * @returns 
 */
export const createRoleUserAPI = (data: RoleParams) => {
  return request('/park/sys/role', 'POST', data)
}

/**
 * 角色管理-修改角色
 * @param data 
 * @returns
 */
export const updateRoleUserAPI = (data: RoleParams) => {
  return request('/park/sys/role', 'PUT', data)
}

/**
 * 删除角色
 * @param roleId 角色id
 * @returns
 */
export const delRoleUserAPI = (roleId: number) => {
  return request(`/park/sys/role/${roleId}`, 'DELETE')
}